package com.bw.zhuangao5___day002.Fragment.Home.Fragment3;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bw.zhuangao5___day002.R;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;


/**
 * create by ertu
 * create on 2021/9/24
 * description
 */
public class ClassBaseAdpter  extends BaseMultiItemQuickAdapter<JavaClass.ResultBean.DataBean, BaseViewHolder> {
    public ClassBaseAdpter(@Nullable List<JavaClass.ResultBean.DataBean> data) {
        super(data);
        addItemType(1, R.layout.homefragment3xml2);
        addItemType(2, R.layout.homefragment3xml3);
        addItemType(3, R.layout.homefragment3xml1);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, JavaClass.ResultBean.DataBean dataBean) {
        switch (dataBean.getItemType())
        {
            case 1:
                Glide.with(getContext()).load(dataBean.getThumbnail_pic_s())
//                        .placeholder(R.mipmap.shaozi1)//还没有发起网络请求,一般空白或者公司logo
//                        .error(R.mipmap.shaozi2)//发起请求失败，一般撕裂
                        .diskCacheStrategy(DiskCacheStrategy.NONE)//关闭磁盘
                        .skipMemoryCache(true)//关闭内存
                        .transform(new CenterCrop(),new RoundedCorners(50))//圆角裁剪
                        .into((ImageView) baseViewHolder.getView(R.id.homefragment3xml2_img));
                break;

            case 2:
                Glide.with(getContext()).load(dataBean.getThumbnail_pic_s02())
//                        .placeholder(R.mipmap.shaozi1)//还没有发起网络请求,一般空白或者公司logo
//                        .error(R.mipmap.shaozi2)//发起请求失败，一般撕裂
                        .diskCacheStrategy(DiskCacheStrategy.NONE)//关闭磁盘
                        .skipMemoryCache(true)//关闭内存
                        .into((ImageView) baseViewHolder.getView(R.id.homefragment3xml3_img));
                break;

            case 3:
                Glide.with(getContext()).load(dataBean.getThumbnail_pic_s())
//                        .placeholder(R.mipmap.shaozi1)//还没有发起网络请求,一般空白或者公司logo
//                        .error(R.mipmap.shaozi2)//发起请求失败，一般撕裂
                        .diskCacheStrategy(DiskCacheStrategy.NONE)//关闭磁盘
                        .skipMemoryCache(true)//关闭内存
                        .into((ImageView) baseViewHolder.getView(R.id.homefragment3xml1_IMG));
                break;
        }
    }



}
